<!DOCTYPE html>
<html>
    <head lang="en">
        <meta charset="UTF-8">
        <meta name="csrf-token" content="{{ csrf_token() }}">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">	
        <link rel="shortcut icon" type="image/x-icon" href="{{URL::asset('handan/images/logo-icon.png')}}" />
        <title>持仓</title>
        <link rel="stylesheet" href="{{URL::asset('mobile/css/public.css') }}"/>
        <link rel="stylesheet" href="{{URL::asset('newmobile/css/chicang.css') }}"/>
        <script src="{{URL::asset('mobile/js/public.js') }}"></script>
        <script src="{{URL::asset('public_js/jquery-3.2.1.min.js')}}"></script>
        <script src="{{ URL::asset('public_js/src/echarts.js') }}"></script>
        <script src="{{ URL::asset('mobile/js/chicang.js') }}"></script>
    </head>
<body>
	<!-- 头部 -->
	<header>
		<div>
			<span>当前持仓</span>
			<span>{{$chicangNum}}</span>
		</div>
		<div>
			<span>浮动收益</span>
			<span class='topfudong'>0</span>
                        <input type="hidden" name="topfudong">
                        <script>
                            topfudong();
                            var j = 0 ,jdata = 0,olddata = 0;
                            setInterval(topfudong,1000);
                            function topfudong(){
                                olddata = $("input[name=topfudong]").val();
                                @foreach($analystData as $k=>$v)
                                    j = $('.all_{{$v->tel}}').html();
                                    if(!parseFloat(j)){
                                        j = 0;
                                    }
                                    jdata = (parseFloat(j) + parseFloat(jdata)).toFixed(1);
                                @endforeach
                                $(".topfudong").html(jdata);
                                if(parseFloat(olddata) < parseFloat(jdata)){
                                    $(".topfudong").css('color','green');
                                }else{
                                    $(".topfudong").css('color','#d72d45');
                                }
                                $("input[name=topfudong]").val(jdata);
                                jdata = 0;
                            }
                        </script>
		</div>
	</header>
	 <!--导航 -->
    @if($analystData)
        @foreach($analystData as $k=>$v)
	<section>
            <div class="list" onclick="showOne(this)">
                <span>
                    <img src="{{$v->photo}}" alt="" />
                </span>
                <span>
                    <p>{{$v->username}}
                        @if($v->isanalyst == 1)
                            <img src="{{URL::asset('newmobile/image/tomorrow.png') }}" alt="" />
                        @else 
                            <img src="{{URL::asset('newmobile/image/vip.png') }}" alt="" />
                        @endif
                    </p>
                    <p><img src="{{URL::asset('newmobile/image/shijain.png') }}" alt="" />{{$v->follow_time}}</p>
                </span>
                <span></span>
                <span class="packUp"><img src="{{URL::asset('newmobile/image/lianshengbang.png') }}" alt="" /></span>
            </div>
            <div class="content">
                    <div class="bianji">
                            <span onclick="flowBtn('{{$v->analyst_id}}','{{$v->followstatus}}')">
                                    <b>编辑</b>
                            </span>
                            <span>
                                    浮动点位：
                                    <b class='all_{{$v->tel}}'></b>
                                    <input type="hidden" name="myold_{{$v->tel}}">
                                    <script>
                                        allfudong();
                                        setInterval(allfudong,1000);
                                        function allfudong(){
                                            var i = 0 , myd = 0 , myold = 0;
                                            myold = $('input[name=myold_{{$v->tel}}]').val();
                                            @foreach($v->list as $kk=>$vv)
                                                i = $('#top_{{$vv->tradeid}}').find('#fu_{{$vv->tradeid}}').html();
                                                if(!parseFloat(i)){
                                                    i = 0;
                                                }
                                                myd = (parseFloat(i) + parseFloat(myd)).toFixed(1);
                                            @endforeach
                                            if( parseFloat(myold) < parseFloat(myd)){
                                                $('.all_{{$v->tel}}').css('color','green');
                                            }else{
                                                $('.all_{{$v->tel}}').css('color','#d72d45');
                                            }
                                            $('.all_{{$v->tel}}').html(myd);
                                            $('input[name=myold_{{$v->tel}}]').val(myd);
                                        }
                                    </script>
                            </span>
                    </div>
                    @foreach($v->list as $kk=>$vv)
                    <div class="danda FX{{$vv->typename}}" onclick="showTwo(this)" id='top_{{$vv->tradeid}}'>
                            <div class="dan">
                                    <p>
                                            <span>{{$vv->chinaname}}<span>{{$vv->typename}}</span></span>
                                            <span class='buy_FX{{$vv->typename}}'>@if($vv->buy_status == 0) 买多 @else 买空 @endif</span>
                                            <span class='fu_FX{{$vv->typename}}' id='fu_{{$vv->tradeid}}'></span>
                                            <!--<input type="hidden" name="fu_{{$vv->tradeid}}">-->
                                            <script>
                                                fudong('{{$vv->tradeid}}','{{$vv->buy_status}}','{{$vv->typename}}','{{$vv->begin_point}}');
                                                setInterval(function(){
                                                   fudong('{{$vv->tradeid}}','{{$vv->buy_status}}','{{$vv->typename}}','{{$vv->begin_point}}');
                                                },1000);
                                            </script>
                                    </p>
                                    <p>
                                            <span>开仓：<span class='open_FX{{$vv->typename}}'>{{$vv->begin_point}}</span></span>
                                            <span>现价：<span class='price_FX{{$vv->typename}}'>0</span></span>
                                    </p>
                            </div>
                            <div class="detailsData">
                                    <p>
                                            <b>
                                                    <span>止盈：{{$vv->target_profit_point}}</span>
                                                    <span>止损：{{$vv->target_loss_point}}</span>
                                            </b>
                                    </p>
                                    <p>
                                            <b>
                                                    <span>单号：{{$vv->tradeid}}</span>
                                                    <span>时间：{{$vv->begin_time}}</span>
                                            </b>
                                    </p>	
                            </div>
                    </div>
                    @endforeach
            </div>
		
	</section>
        @endforeach
    @endif
	<!-- 底部撑块 -->
	<div id="j_bottom" style="height: 5rem;"></div>
	@include('newmobile.footer')
    
<style>
	/*底部行情应用样式*/
	footer ul li:nth-child(2) a {
		color: #3B9CE0;
	}
	footer ul li:nth-child(2) a i {
		display: block;
        background: url("{{URL::asset('mobile/image/ccl.png') }}") no-repeat center/cover;
	}
</style>
@include('mobile.msg')
<script type="text/javascript">
    var starttime = '{{$starttime}}',    //开始策略时间
        endtime   = '{{$endtime}}',      //结束策略时间
        nowtime   = Date.parse(new Date()); // 定时任务
        typenames = '{{$typenames}}',
        timer     = 0;         //定时器    
    var userId = 0;
        
    function showTwo(obj){
            $(obj).find('.detailsData').toggle();
    }
    function showOne(obj){
            $(obj).siblings('.content').toggle(function(){
            if($(obj).siblings(".content").is(":hidden")){
                $(obj).find('.packUp').html('<img src="{{URL::asset('newmobile/image/lianshengbang.png') }}"/>')
            }else{
                $(obj).find('.packUp').html('<img src="{{URL::asset('newmobile/image/shouqi.png') }}"/>')
            }
        });
    }
    
    function flowBtn(id,followstatus){
        userId = id; //分析师的id
        if(followstatus == 1){
           $('#gendancancle').show();
        }else{
            $('#gendancancle').hide();
        }
        $('.follow_btn').toggle();
    }
</script>
@include('newmobile.tanchuang')
</body>
</html>
